package com.lmm.rpc.core.cluster;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Objects;

/**
 * @title: RemoteServer
 * @Description: 注册中心服务提供者节点信息
 * @Author Lmm
 * @Date: 2022/9/29 14:50
 * @Version 1.0
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class RemoteServerInfo {
    /**
     * ip
     * */
    private String ip;

    /**
     * 端口
     * */
    private String port;

    /**
     * 权重
     * */
    private int weight;

    /**
     * 状态 ：可用 不可用
     * */
    private boolean isEnable=true;

    /**
     * 服务名
     * */
    private String server;

    /**
     * 接口名
     * */
    private String serviceName;

    @Override
    public int hashCode() {
        return Objects.hash ( ip, port, weight, isEnable, server ,serviceName);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass () != o.getClass ()) return false;
        RemoteServerInfo totalObject = (RemoteServerInfo) o;
        return weight == totalObject.weight &&
                isEnable == totalObject.isEnable &&
                Objects.equals ( ip, totalObject.ip ) &&
                Objects.equals ( port, totalObject.port ) &&
                Objects.equals ( server, totalObject.server )&&
                Objects.equals(serviceName,totalObject.serviceName);
    }

    @Override
    public String toString() {
        return "RemoteServerInfo{" +
                "ip='" + ip + '\'' +
                ", port='" + port + '\'' +
                ", weight='" + weight + '\'' +
                ", isEnable=" + isEnable +
                '}';
    }

}
